﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;

namespace WS
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public void InserirCliente(Cliente c)
        {
            string strConn = "Data Source=localhost;"
                + "Initial Catalog=PDSD;"
                + "User ID=sa;Password=senha";
            SqlConnection conn = new SqlConnection(strConn);
            SqlCommand cmd = new SqlCommand("insert into Cliente values("
                + "@apelido, @bairro, @cep, @complemento, @dataNascimento, @endereco, @nome, @numero, @sexo, @webSite)", conn);
            conn.Open();

            //cmd.Parameters.AddWithValue("@id", c.id);
            cmd.Parameters.AddWithValue("@apelido", c.apelido);
            cmd.Parameters.AddWithValue("@bairro", c.bairro);
            cmd.Parameters.AddWithValue("@cep", c.cep);
            cmd.Parameters.AddWithValue("@complemento", c.complemento);
            cmd.Parameters.AddWithValue("@dataNascimento", c.dataNascimento);
            cmd.Parameters.AddWithValue("@endereco", c.endereco);
            cmd.Parameters.AddWithValue("@nome", c.nome);
            cmd.Parameters.AddWithValue("@numero", c.numero);
            cmd.Parameters.AddWithValue("@sexo", c.sexo);
            cmd.Parameters.AddWithValue("@webSite", c.webSite);                     
            cmd.ExecuteNonQuery();

            conn.Close();
        }
    }
}